<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <meta name="description" content="">
    <meta name="author" content="">
    <link rel="icon" href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/favicon.ico">
    <link rel="canonical" href="https://getbootstrap.com/docs/3.4/examples/signin/">

    <title>Signin Template for Bootstrap</title>

    <!-- Bootstrap core CSS -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/css/ie10-viewport-bug-workaround.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/examples/signin/signin.css" rel="stylesheet">

    <!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
    <!--[if lt IE 9]><script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
    <script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/js/ie-emulation-modes-warning.js"></script>

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  <script src="moz-extension://182e00ce-9849-4936-a5b4-b8d720db79f8/assets/prompt.js"></script></head>
	<body>
	
	    <div class="container">
	
	      <form class="form-signin">
	        <h2 class="form-signin-heading">管理员登录</h2>
	        <label for="inputEmail" class="sr-only">Email address</label>
	        <input type="email" id="inputEmail" class="form-control" placeholder="Email address" required="" autofocus="">
	        <label for="inputPassword" class="sr-only">Password</label>
	        <input type="password" id="inputPassword" class="form-control" placeholder="Password" required="">
	        <div class="checkbox">
	          <label>
	            <input type="checkbox" value="remember-me"> Remember me
	          </label>
	        </div>
	        <button class="btn btn-lg btn-primary btn-block" type="button" id="btnlogin">Sign in</button>
	      </form>
	
	    </div> <!-- /container -->
	
	
	    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
	    <script src="https://cdn.jsdelivr.net/npm/@bootcss/v3.bootcss.com@1.0.25/assets/js/ie10-viewport-bug-workaround.js"></script>
		<script type="text/javascript" src="https://libs.baidu.com/jquery/1.11.3/jquery.min.js"></script>
		<script src="https://cdn.jsdelivr.net/npm/sweetalert2@8"></script>

		<script type="text/javascript">
			function alertFun(num,txt) {
				if (num == 0) {
					Swal.fire({
						type: 'error',
						title: '失败提示.',
						text: '用户名或密码错误!',
						footer: '<a href>请检查用户名或密码是否正确</a>'
					})
				} else {
					Swal.fire({
						position: 'top-middle',
						type: 'success',
						title: '登录成功!',
						showConfirmButton: true,
						timer: 2500
					})

				}
			}
			$(function(){
				$('#btnlogin').click(function (){
					var username = $('#inputEmail').val();
					var password = $("#inputPassword").val();
					$.ajax({
						async: true,
						url: "./adminlogin.do",
						type: "POST",
						data:{
							action: "adminlogin",
							username: username,
							password: password
						},
						success: function (data) {
							console.log(data);
							var data1 = JSON.parse(data);
							if(data1==0){
								alertFun(0);
							}else{
								alertFun(1,data1);
								window.setTimeout(function (){
									location.href="../admin/adminIndex.html";
								},500);
							}
						},
						dataType: "text"
					});
				})
			})
		</script>
	</body>
</html>
